import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import {VantResolver } from 'unplugin-vue-components/resolvers'

function pathResolve(dir) {
  return resolve(process.cwd(), '.', dir)
};
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VueSetupExtend(),    
    Components({
      resolvers:[
        VantResolver(),
      ]
    }),
    AutoImport({
      // 自动导入vue和vue-router相关函数
      imports: [
            'vue',
            'vue-router',
            'pinia'
        ],
        // dts: 'src/auto-import.d.ts', //生成全局文件
    })
  ],
  css: {
    /* CSS 预处理器 */
    preprocessorOptions: {
      scss: {
        additionalData: '@import "src/assets/styles/main.scss";',
      },
    },
  },
  resolve:{
    alias:{
      '@':pathResolve('src')
    }
  },
  server:{
    host:'192.168.3.12',//ip地址
    port:9001, //端口号
    open:true, //启动后是否自动打开浏览器
    // https: true, //https模式开启
  }
})
